﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Quest
{
    class Bat: Enemy
    {
        // enhancement #1: Make the enemies smarter
        private Dictionary<Levels, int> LevelsMaxDamage = new Dictionary<Levels, int>()
        {
            {Levels.Low, 2},
            {Levels.Medium, 3},
            {Levels.High, 4}
        };
        private static Dictionary<Levels, int> LevelsHitPoints = new Dictionary<Levels, int>()
        {
            {Levels.Low, 6},
            {Levels.Medium, 8},
            {Levels.High, 10}
        };
        private static Dictionary<Levels, int> LevelsMaxRandom = new Dictionary<Levels, int>()
        {
            {Levels.Low, 0},
            {Levels.Medium, 0},
            {Levels.High, 1}
        };

        private int maxDamage;
        // enhancement #1: Make the enemies smarter
        //public Bat(Game game, Point point): base(game, point, 6)
        public Bat(Game game, Point point, Levels level)
            : base(game, point, level, LevelsHitPoints[level])
        {
            maxDamage = LevelsMaxDamage[level]; 
        }

        // enhancement #1: Make the enemies smarter
        //private const int maxDamage = 2;

        public override void Move(Random random)
        {
            // Your code will go here
            Direction myDirection;
            int maxRandom = LevelsMaxRandom[level]; // enhancement #1: Make the enemies smarter
            if (HitPoints > 0)
            {
                if (random.Next(2) <= maxRandom)  // enhancement #1: Make the enemies smarter
                    myDirection = FindPlayerDirection(game.PlayerLocation);
                else
                    myDirection = (Direction)random.Next(0, Enum.GetNames(typeof(Direction)).Length);
                location = Move(myDirection, game.Boundaries);

                if (NearPlayer())
                    game.HitPlayer(maxDamage, random);
            }
        }
    }
}
